#!/bin/bash

cd `dirname $0`
dir=`pwd`
sudo apt install build-essential zlib1g-dev libssl-dev -y
tar xzvf openssh-8.8p1.tar.gz
cd openssh-*
apt install libpam0g-dev libselinux1-dev
mkdir /var/lib/sshd
chmod -R 700 /var/lib/sshd/
chown -R root:sys /var/lib/sshd/
useradd -r -U -d /var/lib/sshd/ -c "sshd privsep" -s /bin/false sshd
./configure --with-pam --with-selinux --with-privsep-path=/var/lib/sshd/ --sysconfdir=/etc/ssh 
make
make install

# 没有被修复
# 因为使用的是 /usr/sbin/sshd
# /usr/bin/ssh -V
# OpenSSH_8.2p1 Ubuntu-4ubuntu0.3, OpenSSL 1.1.1f  31 Mar 2020

# sudo fd --type=x 'ssh'
# 用docker 来测试sshd的升级方法
# https://github.com/rastasheep/ubuntu-sshd/blob/master/18.04/Dockerfile
# https://hub.docker.com/r/rastasheep/ubuntu-sshd/

# 升级到8.8后，发现一些 giteei不能提交的问题
#  ssh -vT git@gitee.com
# debug1: Offering public key: xx@xx RSA SHA256:xxxx agent
# debug1: send_pubkey_test: no mutual signature algorithm
# Fedora 33 ssh RSA 密钥认证 Permission denied 失败问题
# https://lvii.github.io/system/2021-01-26-enable-legacy-ssh-rsa-on-fedora-33-to-fix-ssh-publickey-permission-denied/
PubkeyAcceptedKeyTypes +ssh-rsa